<template>
  <div class="app-container">
    <!-- 搜索表单 -->
   
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
      <el-form-item label="客户名称" prop="cus_name">
        <el-input v-model="queryParams.cus_name" placeholder="请输入客户名称" clearable></el-input>
      </el-form-item>
      <el-form-item label="品名" prop="pro_name">
        <el-input v-model="queryParams.pro_name" placeholder="请输入品名" clearable></el-input>
      </el-form-item>
          <el-form-item label="生产日期" prop="pro_date">
              <el-date-picker type="daterange" v-model="queryParams.pro_date" range-separator="至" start-placeholder="开始日期"
          end-placeholder="结束日期" clearable style="width: 240px" />
            </el-form-item>
      <el-form-item></el-form-item>
      <el-form-item label="产品货号" prop="pro_id">
        <el-input v-model="queryParams.pro_id" placeholder="请输入产品货号" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <!-- 操作按钮 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 数据表格 -->
    <el-tooltip placement="top">
      <div slot="content">点击任意一行，即可在下方查看进度分析详细记录</div>
      <el-table 
        :data="filteredList" 
        border 
        @row-click="showDetail"
        style="width: 100%"
        :row-class-name="rowClassName"
      >
        <el-table-column prop="quality" label="材质" align="center" width="100"></el-table-column>
        <el-table-column prop="cus_name" label="客户名称" align="center" width="120"></el-table-column>
        <el-table-column prop="pro_id" label="产品货号" align="center" width="120"></el-table-column>
        <el-table-column prop="pro_name" label="品名" align="center" width="150"></el-table-column>
        <el-table-column prop="pro_size" label="产品尺寸" align="center" width="120"></el-table-column>
        <el-table-column prop="mo_no" label="模数" align="center" width="80"></el-table-column>
        <el-table-column prop="total_koil" label="造型克重(g)" align="center" width="100"></el-table-column>
        <el-table-column prop="pro_koil" label="产品克重(g)" align="center" width="100"></el-table-column>
         <el-table-column prop="image" label="图片" align="center" width="100"></el-table-column>
          <el-table-column prop="ariti_size" label="铁料尺寸" align="center" width="100"></el-table-column>
        <el-table-column prop="cur_pro_period" label="当前生产阶段" align="center" width="120"></el-table-column>
        <el-table-column prop="is_do" label="是否状态" align="center" width="100">
          <template slot-scope="scope">
            <el-tag :type="scope.row.is_do === '是' ? 'success' : 'danger'">
              {{ scope.row.is_do }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="pro_date" label="生产日期" align="center" width="120"></el-table-column>
        <el-table-column prop="comment" label="备注" align="center" width="120"></el-table-column>
        <el-table-column label="操作" align="center" width="200" fixed="right">
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-edit" @click.stop="handleEdit(scope.row)">编辑</el-button>
            <el-button size="mini" type="text" icon="el-icon-delete" @click.stop="handleDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-tooltip>

    <!-- 分页 -->
    <pagination 
      v-show="total>0"
      :total="total" 
      :page.sync="queryParams.pageNum" 
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 新增/编辑对话框 -->
    <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="800px" append-to-body>
      <el-form :model="form" :rules="rules" ref="formRef" label-width="120px">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="材质" prop="quality">
              <el-select v-model="form.quality" placeholder="请选择材质" style="width:100%" ref="quality">
                <el-option label="密胺" value="密胺"></el-option>
                <el-option label="塑胶" value="塑胶"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="客户名称" prop="cus_name">
              <el-input v-model="form.cus_name" placeholder="请输入客户名称"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="产品货号" prop="pro_id">
              <el-input v-model="form.pro_id" placeholder="请输入产品货号"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="品名" prop="pro_name">
              <el-input v-model="form.pro_name" placeholder="请输入品名"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="产品尺寸(mm)" prop="pro_size">
              <el-input v-model="form.pro_size" placeholder="如: 30.5*18*2.5"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="模数" prop="mo_no">
              <el-input-number v-model="form.mo_no" :min="1" :max="10" label="模数"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="造型克重(g)" prop="total_koil">
              <el-input-number v-model="form.total_koil" :min="0" :precision="2" :step="0.1"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="产品克重(g)" prop="pro_koil">
              <el-input-number v-model="form.pro_koil" :min="0" :precision="2" :step="0.1"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="铁料尺寸(mm)" prop="ariti_size">
              <el-input v-model="form.ariti_size" placeholder="请输入铁料尺寸"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="生产日期" prop="pro_date">
              <el-date-picker 
                v-model="form.pro_date" 
                type="date" 
                placeholder="选择日期"
                value-format="yyyy-MM-dd"
                style="width:100%"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="当前生产阶段" prop="cur_pro_period">
      <el-select v-model="form.cur_pro_period" placeholder="请选择生产阶段" style="width:100%" v-if="type1">
       <el-option label="测绘" value="测绘"></el-option>
        <el-option label="造型" value="造型"></el-option>
        <el-option label="下料" value="下料"></el-option>
        <el-option label="加工中心:开粗" value="加工中心:开粗"></el-option>
        <el-option label="加工中心:精雕" value="加工中心:精雕"></el-option>
        <el-option label="配模" value="配模"></el-option>
        <el-option label="打火花" value="打火花"></el-option>
        <el-option label="打光" value="打光"></el-option>
        <el-option label="电镀" value="电镀"></el-option>
        <el-option label="收光" value="收光"> </el-option>
      </el-select>
      <el-select v-model="form.cur_pro_period" placeholder="请选择生产阶段" style="width:100%" v-else>
        <el-option label="测绘" value="测绘"></el-option>
        <el-option label="造型" value="造型"></el-option>
        <el-option label="下料" value="下料"></el-option>
        <el-option label="加工中心:开粗" value="加工中心:开粗"></el-option>
        <el-option label="加工中心:精雕" value="加工中心:精雕"></el-option>
        <el-option label="加工中心:其他加工" value="加工中心:其他加工"></el-option>
        <el-option label="配模" value="配模"></el-option>
        <el-option label="组装" value="组装"></el-option>
        <el-option label="试模" value="试模"></el-option>
        <el-option label="打光" value="打光"></el-option>
        <el-option label="电镀" value="电镀"></el-option>
        <el-option label="收光" value="收光"></el-option>
      </el-select>
    </el-form-item>
         
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否完成" prop="is_do">
              <el-radio-group v-model="form.is_do">
                <el-radio label="是">是</el-radio>
                <el-radio label="否">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-form-item label="产品图片" prop="image">
          <el-upload
            action="https://jsonplaceholder.typicode.com/posts/"
            list-type="picture-card"
            :on-preview="handlePictureCardPreview"
            :on-remove="handleRemove"
            :file-list="fileList"
          >
            <i class="el-icon-plus"></i>
          </el-upload>
        </el-form-item>
        
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" :rows="2" placeholder="请输入备注信息"></el-input>
        </el-form-item>
      </el-form>
      
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="submitForm">确 定</el-button>
      </div>
    </el-dialog>


<br>
<br>
<br>
<hr>
<h2 align="center">{{name}}模具生产派工及生产进度   </h2>
<br>


  <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd1">新增</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
      <el-table :data="dispatch_data"
        border 
        highlight-current-row 
        style="width: 100%"
        v-if="type">
      
        <el-table-column label="工序名称" align="center" prop="order_name"></el-table-column>
        <el-table-column label="加工人" align="center" prop="add_man"></el-table-column>
        <el-table-column label="计划完成时间" align="center" prop="plan_time"></el-table-column>
        <el-table-column label="实际完成时间" align="center" prop="indeed_time"></el-table-column>
        <el-table-column label="完成状态" align="center" prop="do_status" width="100">
            <template slot-scope="scope">
            <el-tag :type="scope.row.do_status === '是' ? 'success' : 'danger'">
              {{ scope.row.do_status }}
            </el-tag>
          </template>
           </el-table-column>
        <el-table-column label="操作" align="center" fixed="right">
          <template slot-scope="scope" >
             <el-button size="mini" type="text" icon="el-icon-edit" @click.stop="handleEdit(scope.row)">编辑</el-button>
            <el-button size="mini" type="text" icon="el-icon-delete" @click.stop="handleDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
        <el-table :data="dispatch_data1"
        border 
        highlight-current-row 
        style="width: 100%"
        v-else>
      
        <el-table-column label="工序名称" align="center" prop="order_name"></el-table-column>
        <el-table-column label="加工人" align="center" prop="add_man"></el-table-column>
        <el-table-column label="计划完成时间" align="center" prop="plan_time"></el-table-column>
        <el-table-column label="实际完成时间" align="center" prop="indeed_time"></el-table-column>
        <el-table-column label="完成状态" align="center" prop="do_status" width="100">
            <template slot-scope="scope">
            <el-tag :type="scope.row.do_status === '是' ? 'success' : 'danger'">
              {{ scope.row.do_status }}
            </el-tag>
          </template>
           </el-table-column>
        <el-table-column label="操作" align="center" fixed="right">
          <template slot-scope="scope" >
             <el-button size="mini" type="text" icon="el-icon-edit" @click.stop="handleEdit(scope.row)">编辑</el-button>
            <el-button size="mini" type="text" icon="el-icon-delete" @click.stop="handleDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>





  <el-dialog :title="title2" :visible.sync="open2" width="800px" append-to-body>
   <el-form :model="form1" label-width="120px">
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item label="工序名称">
      <el-select v-model="form1.order_id" v-if="type">
        <el-option label="测绘" value="测绘"></el-option>
        <el-option label="造型" value="造型"></el-option>
        <el-option label="下料" value="下料"></el-option>
        <el-option label="加工中心:开粗" value="加工中心:开粗"></el-option>
        <el-option label="加工中心:精雕" value="加工中心:精雕"></el-option>
        <el-option label="配模" value="配模"></el-option>
        <el-option label="打火花" value="打火花"></el-option>
        <el-option label="打光" value="打光"></el-option>
        <el-option label="电镀" value="电镀"></el-option>
        <el-option label="收光" value="收光"> </el-option>
      </el-select >
       <el-select v-model="form1.order_id" v-else>
        <el-option label="测绘" value="测绘"></el-option>
        <el-option label="造型" value="造型"></el-option>
        <el-option label="下料" value="下料"></el-option>
        <el-option label="加工中心:开粗" value="加工中心:开粗"></el-option>
        <el-option label="加工中心:精雕" value="加工中心:精雕"></el-option>
        <el-option label="加工中心:其他加工" value="加工中心:其他加工"></el-option>
        <el-option label="配模" value="配模"></el-option>
        <el-option label="组装" value="组装"></el-option>
        <el-option label="试模" value="试模"></el-option>
        <el-option label="打光" value="打光"></el-option>
        <el-option label="电镀" value="电镀"> </el-option>
        <el-option label="收光" value="收光"> </el-option>
      </el-select>
    </el-form-item>
      </el-col>
       <el-col :span="12">
        <el-form-item label="加工人">
      <el-input v-model="form1.add_man"></el-input>
    </el-form-item>
      </el-col>
    </el-row>
     <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item label="计划完成时间">
     <el-date-picker 
                v-model="form1.pro_date1" 
                type="date" 
                placeholder="选择日期"
                value-format="yyyy-MM-dd"
                style="width:100%"
              ></el-date-picker>
    </el-form-item>
      </el-col>
       <el-col :span="12">
        
    <el-form-item label="实际完成时间">
<el-date-picker 
                v-model="form1.pro_date2" 
                type="date" 
                placeholder="选择日期"
                value-format="yyyy-MM-dd"
                style="width:100%"
              ></el-date-picker>
    </el-form-item>
      </el-col>
    </el-row>
     <el-row :gutter="20">
      <el-col :span="12">
     
        <el-form-item label="完成状态" prop="is_do">
              <el-radio-group v-model="form1.is_do">
                <el-radio label="是">是</el-radio>
                <el-radio label="否">否</el-radio>
              </el-radio-group>
        
    </el-form-item>
      </el-col>
       
    </el-row>
   </el-form>
       <div slot="footer" class="dialog-footer">
        <el-button @click="open2 = false">取 消</el-button>
        <el-button type="primary" @click="submitForm1">确 定</el-button>
      </div>
    </el-dialog>
    









  </div>
</template>

<script>
export default {
  name: 'ProductionManagement',
  data() {
    return {
        type:false,
        type1:false,
      name:'',
      activeName:'first',
      showCard:true,
      title2:"",
      open2:false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        cus_name: '',
        pro_name: '',
        pro_id: '',
        quality: ''
      },
      form1:{
        order_id:'',
        add_man:'',
        pro_date1:'',
        pro_date2:'',
        is_do:''

      },
      // 表单数据
      form: {
        id: undefined,
        quality: '',
        cus_name: '',
        pro_id: '',
        pro_name: '',
        pro_size: '',
        mo_no: 1,
        total_koil: 0,
        pro_koil: 0,
        ariti_size: '',
        image: '',
        cur_pro_period: '',
        is_do: '否',
        pro_date: '',
        orderly: 1,
        remark: ''
      },
      
      // 表单验证规则
      rules: {
        cus_name: [{ required: true, message: '客户名称不能为空', trigger: 'blur' }],
        pro_id: [{ required: true, message: '产品货号不能为空', trigger: 'blur' }],
        pro_name: [{ required: true, message: '品名不能为空', trigger: 'blur' }],
        pro_size: [{ required: true, message: '产品尺寸不能为空', trigger: 'blur' }],
        cur_pro_period: [{ required: true, message: '请选择当前生产阶段', trigger: 'change' }],
        pro_date: [{ required: true, message: '请选择生产日期', trigger: 'change' }]
      },
      dispatch_data:[
        {
         
          order_name:"测绘",
          add_man:"小李",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"造型",
          add_man:"小开",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"下料",
          add_man:"小里",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"开粗",
          add_man:"小品",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"精雕",
          add_man:"小嚄",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"配模",
          add_man:"小看",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"打火花",
          add_man:"小什",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"打光",
          add_man:"小粗",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"电镀",
          add_man:"小来",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"收光",
          add_man:"小否",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"电镀",
          add_man:"小个",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
     
      ]
      ,
     dispatch_data1:[
        {
         
          order_name:"测绘",
          add_man:"小李",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"造型",
          add_man:"小我",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"下料",
          add_man:"小完",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
       {
         
          order_name:"开粗",
          add_man:"小的",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"精雕",
          add_man:"小个",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"其他加工",
          add_man:"小个",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
       {
         
          order_name:"外加工",
          add_man:"小好",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"配模",
          add_man:"小在",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"组装",
          add_man:"小壹",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
       {
         
          order_name:"试模",
          add_man:"小他",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"打光",
          add_man:"小配",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
      {
        
          order_name:"电镀",
          add_man:"小个",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
       {
         
          order_name:"收光",
          add_man:"小表",
          plan_time:"2025-02-07",
          indeed_time:"2025-03-05",
          do_status:"否"
      },
     
      ]
      ,
      // 表格数据
      module_pro_data: [
        {
          id: 1,
          quality: "密胺",
          cus_name: "小王",
          pro_id: "YL037619",
          pro_name: "长方鱼片",
          pro_size: "30.5*18*2.5",
          mo_no: 2,
          total_koil: 250,
          pro_koil: 283,
          ariti_size: '',
          image: '',
          cur_pro_period: '打包',
          is_do: "否",
          pro_date: "2025-03-08",
          orderly: 1,
          comment:''
        },
        {
          id: 2,
          quality: "密胺",
          cus_name: "小李",
          pro_id: "YL037614",
          pro_name: "圆形厚浅碟",
          pro_size: "30.5*18*2.9",
          mo_no: 2,
          total_koil: 250,
          pro_koil: 283,
          ariti_size: '',
          image: '',
          cur_pro_period: '打包',
          is_do: "否",
          pro_date: "2025-03-08",
          orderly: 1,
          comment:''
        },
        {
           id: 3,
          quality: "塑胶",
          cus_name: "小里",
          pro_id: "YL037612",
          pro_name: "长方鱼片",
          pro_size: "30.5*18*2.5",
          mo_no: 2,
          total_koil: 250,
          pro_koil: 283,
          ariti_size: '',
          image: '',
          cur_pro_period: '打包',
          is_do: "否",
          pro_date: "2025-03-08",
          orderly: 1,
          comment:''
        }
      ],
      
      // 分页数据
      total: 0,
      loading: false,
      dialogVisible: false,
      dialogTitle: '',
      dialogType: '',
      showSearch: true,
      fileList: [],
      
      // 高亮
      proId: '',
    }
  },
  watch:{
     'form.quality': function() {
      if (this.form.quality === "密胺") {
        this.type1 = true;
      } else {
        this.type1 = false;
      }
    
    }
  },
  computed: {
    // 过滤后的列表数据
    filteredList() {
      return this.module_pro_data.filter(item => {
        return (
          (!this.queryParams.cus_name || item.cus_name.includes(this.queryParams.cus_name)) &&
          (!this.queryParams.pro_name || item.pro_name.includes(this.queryParams.pro_name)) &&
          (!this.queryParams.pro_id || item.pro_id.includes(this.queryParams.pro_id)) &&
          (!this.queryParams.quality || item.quality === this.queryParams.quality)
        )
      })
    }
  },
  created() {
    this.getList()
  },
  methods: {
     // 显示高亮
     rowClassName({ row }) {
       return row.pro_id == this.proId ? 'selected-row' : ''; // 判断是否选中
     },
    // 获取列表数据
    getList() {
      // 这里应该是API调用，暂时用模拟数据
      this.total = this.module_pro_data.length
    },
    
    // 查询
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    
    // 重置查询
    resetQuery() {
      this.$refs.queryForm.resetFields()
      this.handleQuery()
    },
    
    // 显示详情
    showDetail(row) {
this.name = row.cus_name;
this.proId = row.pro_id;
if(row.quality==="密胺"){
    this.type=true;
}
else{
    this.type=false;
}
      // 可以在这里添加显示详情的逻辑
    },
    
    // 新增
    handleAdd() {
      this.dialogTitle = '新增模具生产记录'
      this.dialogType = 'add'
      this.dialogVisible = true
      this.$nextTick(() => {
        this.$refs.formRef.resetFields()
        this.form.id = undefined
      })
    },
    handleAdd1(){
      this.title2="新增模具生产派工及生产进度详情"
      this.open2="true"
    },
    
    // 编辑
    handleEdit(row) {
      this.dialogTitle = '编辑生产记录'
      this.dialogType = 'edit'
      this.dialogVisible = true
      this.$nextTick(() => {
        this.form = Object.assign({}, row)
      })
    },
    
    
  
    
    // 删除
    handleDelete(row) {
      this.$confirm(`确认删除 "${row.pro_name}" 的生产记录吗?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const index = this.module_pro_data.findIndex(item => item.id === row.id)
        if (index !== -1) {
          this.module_pro_data.splice(index, 1)
          this.$message.success('删除成功')
          this.getList()
        }
      }).catch(() => {
        this.$message.info('已取消删除')
      })
    },
    
    // 提交表单
    submitForm() {
      this.$refs.formRef.validate(valid => {
        if (valid) {
          if (this.dialogType === 'add') {
            // 新增
            this.form.id = this.module_pro_data.length + 1
            this.module_pro_data.push(Object.assign({}, this.form))
            this.$message.success('新增成功')
          } else {
            // 编辑
            const index = this.module_pro_data.findIndex(item => item.id === this.form.id)
            if (index !== -1) {
              this.module_pro_data.splice(index, 1, Object.assign({}, this.form))
              this.$message.success('修改成功')
            }
          }
          this.dialogVisible = false
          this.getList()
        }
      })
    },
    submitForm1(){
      this.open2=false
     
    },
    
    // 图片上传相关方法
    handleRemove(file, fileList) {
      console.log(file, fileList)
    },
    handlePictureCardPreview(file) {
      console.log(file)
    }
  }
}
</script>

<style>
.app-container {
  padding: 20px;
}
.el-row {
  margin-bottom: 20px;
}
.el-table {
  margin-top: 20px;
}
.selected-row {
  background-color: yellow !important;
  /* 选中行的背景颜色 */
}
</style>
